#!/usr/bin/env python
# -*- coding: utf-8
import time
import sys
sys.path.append('../mavlink')
import pymavlink
from pymavlink import mavutil


# Open connection
Mav = mavutil.mavlink_connection('/dev/ttyACM0', 115200)

while True:
	msg = Mav.recv_match(blocking = True)
	if not msg:
		print "Not msg"
		break

	if msg.get_type() == 'BAD_DATA':
		if mavutil.all_printable(msg.data):
			sys.stdout.write(msg.data)
			sys.stdout.flush()
	else:
		print msg

